<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        li {
            list-style: none;
        }
        .top {
            width: 403px;
            height: 30px;
            border: 1px dotted black;

        }
        .top ul {
            overflow: hidden
        }
        .top ul li {
            float: left;
            width: 100px;
            height: 27px;
            text-align: center;
            line-height: 30px;
            border-top: 3px solid transparent;
            font-size: 18px;
        }
        .top ul li.current {
            border-top: 3px solid red;
        }
        .bottom {
            width: 1000px;
            height: 475px;
            position: relative;
        }
        .bottom> div {
            position: absolute;
            display: none;
        }
        .bottom> div.current {
            display: block;
        }
    </style>
</head>
<body>
    <div class="tabbar">
        <div class="top">
            <ul>
                <li class='current'>国际大牌</li>
                
                <li>国妆名牌</li>
                
                <li>清洁用品</li>
                
                <li>男士精品</li>
            </ul>
        </div>
        <div class="bottom">
            <div class='one current'><img src="imgs/guojidapai.jpg" alt=""></div>
            <div class='two'><img src="imgs/guozhuangmingpin.jpg" alt=""></div>
            <div class='three'><img src="imgs/qingjieyongpin.jpg" alt=""></div>
            <div class='four'><img src="imgs/nanshijingpin.jpg" alt=""></div>
        </div>
    </div>
    <script>
        //获取元素
        var divList = document.querySelectorAll('.bottom>div');
        var liList = document.querySelectorAll('.top li')
        //注册事件
        //鼠标放入tab标签,添加样式,并且对应的div跟着下标切换
        for(var i = 0; i < liList.length; i++){
            liList[i].onmouseenter = liMouseenter
        }
        function liMouseenter(){
            for(var i = 0; i < liList.length; i++) {
                var arr = divList[i].className.match(/\w+/)
                if(this == liList[i]) {
                    this.className = 'current';
                    divList[i].className += ' current' 
                }else {
                    liList[i].className = '';
                    divList[i].className = arr;
                }
            }
        }
    </script>
    <script src='../jquery-1.12.4.js'></script>
    <script>
        // $(function(){
        //     $('.top li').on('mouseenter',function(){
        //         $(this).addClass('current').siblings().removeClass('current');
        //         $('.bottom>div').eq($(this).index()).show().siblings().hide();
        //     })
        // })
    </script>
</body>
</html>